import { Module } from '@nestjs/common';
import { UserAccountService } from './user_account.service';
import { UserAccountController } from './user_account.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserAccount } from './entities/user_account.entity'
import { UserHobby } from './entities/user_hobby.entity';
import { Article } from 'src/article/entities/article.entity';
import { ArticleComment } from 'src/article/entities/comment.entity';
import { Announcement } from './entities/announcement.entity';
import { MulterModule } from '@nestjs/platform-express';
import { diskStorage } from 'multer';
import { extname, join } from 'path';

@Module({
  imports: [TypeOrmModule.forFeature([UserAccount, UserHobby, Article, ArticleComment, Announcement]),
  MulterModule.register({
    storage: diskStorage({
      destination: join(__dirname, "../images"),
      filename: (_, file, callback) => {
        //给图片重命名
        const fileName = `${new Date().getTime() + extname(file.originalname)}`
        return callback(null, fileName)
      }
    })
  })
  ],
  controllers: [UserAccountController],
  providers: [UserAccountService]
})
export class UserAccountModule { }
